
#coding:utf-8

from  datetime  import  *
import  time

def githubTime(stringtime) :
    #get from title
    #title: title="Apr 24, 2017, 8:35 AM GMT+8"
    #value: stringtime eg. Sep 6,2016
    monthTable = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4,\
            'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8,\
             'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec':12}
    # year = stringtime[6: 10]
    # month = monthTable[stringtime[0: 3]]
    # day = stringtime[4]
    year = stringtime.split(',')[1][1:]
    daymonth = stringtime.split(',')[0]
    #默认按空格分割
    month = monthTable[daymonth.split()[0]]
    day = daymonth.split()[1]
    # print year , month, day
    submitTime = date(int(year), int(month), int(day))
    nowTime = date.today()
    dayDiff = nowTime - submitTime
    # print submitTime
    return dayDiff.days

#print githubTime('Apr 26, 2017, 6:11 PM GMT+8')

